<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%--
  Created by IntelliJ IDEA.
  User: wk
  Date: 2020/5/11
  Time: 21:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css" type="text/css">
    <style type="text/css">
        .layui-table-cell{ text-align: center; height: auto; white-space: normal; }
    </style>
    <script>
        function myTable(){
            layui.table.render({
                elem: '#guruTable' //指定原始表格元素选择器（推荐id选择器）
                ,page:true
                ,url:'${pageContext.request.contextPath}/guru/findAll'
                // ,toolbar:"#myToolBar"
                ,cols: [[
                    {field:'guruId',title:'ID'},
                    {field:'guruName',title:'上师名称'},
                    {field:'guruImage',title:'头像',templet:
                        '<div><img src="${pageContext.request.contextPath}/img/{{d.guruImage}}"></div>'
                        },
                    {field:'nickName',title:'法号'},
                    {field:'guruStatus',title:'状态',templet:function (d) {
                            return d.guruStatus==1?"在世":"圆寂"
                        }},

                    {title:'操作',templet:"#caozuoTpl",align:"center"}
                ]] //设置表头
                //,…… //更多参数参考右侧目录：基本参数选项
            });
        }
        layui.use(['element','jquery','table','upload','form'], function() {
            element = layui.element;
            var table = layui.table;
            var upload = layui.upload;
            var form = layui.form;
            myTable();

            //指定允许上传的文件类型
            upload.render({
                elem: '#test3'
                ,url: '${pageContext.request.contextPath}/guru/uploadExcel' //改成您自己的上传接口
                ,accept: 'file' //普通文件
                ,size:1024*1024*1024
                ,done: function(res){
                    layer.msg('上传成功');
                    console.log(res.data);
                    table.reload("guruTable")
                }
            });
        })
        function exportExcel() {
            alert(21)
            window.location.href="/cmfz/guru/download"
        }

    </script>

<!--操作模板 -->
<script type="text/html" id="caozuoTpl">
    <button type="button" class="layui-btn layui-btn-danger" onclick="delete({{d.guruId}})">删除</button>
    <button type="button" class="layui-btn" onclick="toUpdate({{d.guruId}})">修改</button>
</script>
</head>



<body>
<shiro:hasRole name="superadmin">
<button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>批量上传</button>
<button type="button" class="layui-btn" id="download" onclick="exportExcel()" ><i class="layui-icon"></i>批量下载</button>
</shiro:hasRole>
<table id="guruTable"> </table>
<script type="text/javascript">

</script>
</body>
</html>
